<%--
  Created by IntelliJ IDEA.
  User: 10161
  Date: 2019/1/8
  Time: 19:29
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/css/common.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/css/main.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/js/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/js/colResizable-1.3.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/js/common.js"></script>

    <script type="text/javascript">
        $(function(){
            $(".list_table").colResizable({
                liveDrag:true,
                gripInnerHtml:"<div class='grip'></div>",
                draggingClass:"dragging",
                minWidth:30
            });

        });
    </script>

    <script type="text/javascript">
        function deleteNewsType(id) {
            $.get("/newstype/dodelete",{id:id},function (result) {
                if (!confirm("删除类别会删除所有其子类，你确定要删除嘛！")){
                    return ;
                }
                if(result=="1"){
                    alert("删除成功");
                }else {
                    alert("删除失败");

                }
                window.location= window.location;
            });
        }

        $(function () {
            $("#cbAll").click(function () {
                $("input[name='cbItem']").prop("checked", $("#cbAll").prop("checked"));
            });
        });
        function deleteAllNewsType () {
            if (!confirm("删除类别会删除所有其子类，你确定要删除嘛！")){
                return ;
            }
            var ids ="-1";
            $("input[name='cbItem']").each(function () {
                if(this.checked){
                    var id= $(this).val();
                    ids+=","+id;
                }
            });
            $.get("${pageContext.request.contextPath }/newstype/dodeleteall",{ids:ids},function (result) {
                if(result=="1"){
                    alert("批量删除成功");
                }else {
                    alert("批量删除失败");
                }
                window.location= window.location;
            });
        }
    </script>

    <title>Document</title>
</head>
<body>
<div class="container">

    <%--<div id="button" class="mt10">--%>
    <%--<input type="button" name="button" class="btn btn82 btn_add" value="新增">--%>
    <%--<input type="button" name="button" class="btn btn82 btn_del" value="删除">--%>
    <%--<input type="button" name="button" class="btn btn82 btn_config" value="配置">--%>
    <%--<input type="button" name="button" class="btn btn82 btn_count" value="统计">--%>
    <%--<input type="button" name="button" class="btn btn82 btn_checked" value="全选">--%>
    <%--<input type="button" name="button" class="btn btn82 btn_nochecked" value="取消">--%>
    <%--<input type="button" name="button" class="btn btn82 btn_export" value="导出">--%>
    <%--<input type="button" name="button" class="btn btn82 btn_recycle" value="回收站">--%>
    <%--<input type="button" name="button" class="btn btn82 btn_search" value="查询">--%>
    <%--</div>--%>

        <form action="${pageContext.request.contextPath}/newstype/list" method="post">
    <div id="search_bar" class="mt10">
        <div class="box">
            <div class="box_border">
                <div class="box_top"><b class="pl15">搜索</b></div>
                <div class="box_center pt10 pb10">
                    <table class="form_table" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td>类别名称</td>
                            <td><input type="text" name="typeName" value="${newsType.typeName}" class="input-text lh25" size="10"></td>
                            <td>父类别</td>
                            <td>
                    <span class="fl">
                      <div class="select_border">
                        <div class="select_containers ">
                        <select name="parentId" class="select">
                        <option value="0">==不限==</option>
                        <c:forEach var="item" items="${plist}">
                            <option <c:if test="${item.id==newsType.parentId}">selected="selected"</c:if>
                                    value="${item.id}">${item.typeName}</option>
                        </c:forEach>
                        </select>
                        </div>
                      </div>
                    </span>
                            </td>
                    </table>
                </div>

                <div class="box_bottom pb5 pt5 pr10" style="border-top:1px solid #dadada;">
                    <div class="search_bar_btn" style="text-align:right;">
                        <input type="submit" value="确定" class="ext_btn ext_btn_submit">
                        <input type="button" value="返回" onclick="location.href='javascript:history.go(-1)'" class="ext_btn">
                        <input type="button" class="ext_btn ext_btn_error" onclick="deleteAllNewsType()" value="删除">
                        <a href="${pageContext.request.contextPath}/newstype/save" class="ext_btn"><span class="add"></span>添加</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
        </form>
    <div id="table" class="mt10">
        <div class="box span10 oh">
            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="list_table">
                <tr>
                    <th width="30"><td><input type="checkbox" id="cbAll"/></th>
                    <th width="100">ID</th>
                    <th width="100">类别名称</th>
                    <th width="100">父类别</th>
                    <th width="100">创建日期</th>
                    <th>操作</th>
                </tr>
                <c:forEach items="${list}" var="li">
                <tr class="tr">
                    <td class="td_center"><input type="checkbox" name="cbItem" value="${li.id}"/></td>
                    <td>${li.id}</td>
                    <td>${li.typeName}</td>
                    <td>${li.parentName}</td>
                    <td><fmt:formatDate value="${li.createDate}" pattern="yyyy-MM-dd HH:mm"/></td>
                    <td><a href="${pageContext.request.contextPath}/newstype/update?id=${li.id}">修改</a>
                        <a href="javascript:void(0)" onclick="deleteNewsType(${li.id});">删除</a></td>
                </tr>
                </c:forEach>
            </table>

            <div class="page mt10">
                <div class="pagination">
                    <ul>
                        <li class="first-child"><a href="${pageContext.request.contextPath }/newstype/list?typeName=${newsType.typeName}&parentId
        =${newsType.parentId}&currPageNo=1">首页</a></li>
                        <li class="disabled"><a href="${pageContext.request.contextPath }/newstype/list?typeName=${newsType.typeName}&parentId
        =${newsType.parentId}&currPageNo=${pageTool.currPageNo-1}">上一页</a></li>
                        <c:forEach var="prePage" items="${prePages}">
                            <li><a href="${pageContext.request.contextPath }/newstype/list?typeName=${newsType.typeName}&parentId
        =${newsType.parentId}&currPageNo=${pageTool.currPageNo-1}">${prePage}</a></li>
                        </c:forEach>
                        <li class="active"><span>${pageTool.currPageNo}</span></li>
                        <c:forEach var="nextPage" items="${nextPages}">
                            <li><a href="${pageContext.request.contextPath }/newstype/list?typeName=${newsType.typeName}&parentId
        =${newsType.parentId}&currPageNo=${pageTool.currPageNo+1}">${nextPage}</a></li>
                        </c:forEach>
                        <li><a href="${pageContext.request.contextPath }/newstype/list?typeName=${newsType.typeName}&parentId
        =${newsType.parentId}&currPageNo=${pageTool.currPageNo+1}">下一页</a></li>
                        <li><a href="${pageContext.request.contextPath }/newstype/list?typeName=${newsType.typeName}&parentId
        =${newsType.parentId}&currPageNo=${pageTool.pageCount}">末页</a></li>
                    </ul>
                </div>

            </div>

        </div>
    </div>
</div>
</body>
</html>
